exports.notEmpty = (name) => (v) =>
  !v || v.trim() === '' ? `${name} is required` : true

/**
 * 连接线转大驼峰
 * @param {string} fieldName 需要转换的字符串
 */
exports.bigCamelCase = (fieldName) => {
  const stringPices = fieldName.trim().split('-')
  const bigCamelCaseStringPices = stringPices.map(
    (s) => s.substring(0, 1).toUpperCase() + s.substring(1)
  )
  return bigCamelCaseStringPices.join('')
}

/*
 * 连接线转小驼峰
 * @param {string} fieldName 需要转换的字符串
 */
exports.smallCamelCase = (fieldName) => {
  const stringPices = fieldName.trim().split('-')
  const bigCamelCaseStringPices = stringPices.map((s, i) => {
    if (i !== 0) {
      return s.substring(0, 1).toUpperCase() + s.substring(1)
    }
    return s
  })
  return bigCamelCaseStringPices.join('')
}
